package com.spring.nio.business.user.service;

import com.spring.nio.business.user.constant.UserStatusEnum;
import com.spring.nio.business.user.dto.UserDTO;
import com.spring.nio.business.user.param.UserCreateParam;
import com.spring.nio.business.user.param.UserQueryParam;
import com.spring.nio.business.user.param.UserUpdateParam;
import com.spring.nio.core.channel.handler.AbstractChannelHandler;
import com.spring.nio.core.configuration.NioServerBootstrap;
import com.spring.nio.core.event.handler.ReadEventHandler;
import com.spring.nio.core.server.FileSystemServer;
import com.spring.nio.service.file.model.structure.FileTransportTaskDTO;
import com.spring.nio.service.file.task.FileDownloadStreamCallable;
import com.spring.nio.util.LocalTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 用户服务
 *
 * @author spring
 * */
public interface UserService {

    /**
     * key: remoteAddress: 当前用户所占用的远程地址  value: 当前登陆成功用户信息
     * */
    Map<String, UserDTO> onlineUser = new ConcurrentHashMap<>();

    /**
     * 用户下线 释放文件上传和下载任务
     * @param remoteAddress
     * @param isClearSingleFileUploadTask 是否单独清除remoteAddress对应的上传任务
     * @param isClearSingleFileDownloadTask 是否单独清除remoteAddress对应的下载任务
     * @param isLogout 是否执行用户下线
     * */
    void offlineUser(String remoteAddress, Boolean isLogout, Boolean isClearSingleFileUploadTask, Boolean isClearSingleFileDownloadTask);

    /**
     * 获取用户在线情况,内存根据用户名获取
     * @param param
     * @return userDto
     */
    UserDTO getOnlineUserByName(UserQueryParam param);

    /**
     * 获取用户在线情况,内存根据用户Id获取
     * @param param
     * @return userDto
     */
    UserDTO getOnlineUserById(UserQueryParam param);

    /**
     * 根据用户名查询指定用户
     * @param userQueryParam
     * @return userDto
     */
    UserDTO getUserByName(UserQueryParam userQueryParam);

    /**
     * 根据用户名模糊查询用户
     * @param userQueryParam
     * @return List<UserDTO>
     * */
    List<UserDTO> getFuzzyQueryUserByName(UserQueryParam userQueryParam);

    /**
     * 创建用户
     * @param userCreateParam
     * @return userDto
     */
    UserDTO create(UserCreateParam userCreateParam);

    /**
     * 更新用户
     * @param userUpdateParam
     * @return userDto
     */
    void update(UserUpdateParam userUpdateParam);
}
